package com.xyzwps.harbor.model;

import com.xyzwps.harbor.util.ErrorCode;
import com.xyzwps.harbor.util.HarborException;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

import java.time.LocalDateTime;


@Table("users")
public class User {
    @Id
    private Long userId;
    private String username;
    private String avatar;
    private String nickName;
    private LocalDateTime registerTime;
    private UserStatus status;

    public User shouldBeActive() {
        if (this.status != UserStatus.ACTIVE) {
            throw HarborException.badRequestEx("User was " + this.status, ErrorCode.INACTIVE_USER);
        }
        return this;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public LocalDateTime getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(LocalDateTime registerTime) {
        this.registerTime = registerTime;
    }

    public UserStatus getStatus() {
        return status;
    }

    public void setStatus(UserStatus status) {
        this.status = status;
    }
}